<?php
//用户列表的遍历展示
  include_once("./com.php");
  $rem="select * from user";
  
$rs=mysql_query($sql);
$info=[];
$totalRows=mysql_num_rows($rs);
$pageRows=4;
$totalPage=ceil($totalRows / $pageRows);
$page=isset($_GET['page'])?$_GET['page']:1;
if ($page<=0||$page>$totalPage||!is_numeric($page)) {
  $page=1;
}
//5.处理limit查询的第一个参数，分页计算公式
$limitstart=$pageRows * ($page-1);
//6.组装sql语句
$sql="SELECT * FROM tk_admin order by admin_id desc limit {$limitstart},{$pageRows}";
//7.获取分页数据
$re=mysql_query($sql);
$info=[];
if(mysql_num_rows($re)>0){
  while($arr=mysql_fetch_assoc($re)){
    $info[]=$arr;
  }
}

  $ser=mysql_query($rem);
  while($res=mysql_fetch_assoc($ser)){
    $ree[]=$res;
  };

?>



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户列表</title>
<base target="_self">
<link rel="stylesheet" type="text/css" href="skin/css/base.css" />
<link rel="stylesheet" type="text/css" href="skin/css/main.css" />
</head>
<body leftmargin="8" topmargin='8'>
<table width="98%" align="center" border="0" cellpadding="3" cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom:8px;margin-top:8px;">
  <tr>
    <td background="skin/images/frame/wbg.gif" bgcolor="#EEF4EA" class='title' colspan="2"><span><img src='skin/images/frame/arr3.gif' style='margin-right:10px;'>用户列表</span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    	 <td colspan="2">
    	 	<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CFCFCF" align="center" style="margin-top:8px">
    	 	<tr align="center" bgcolor="#FBFCE2" height="25">
          <th>ID</th>
    	 		<th>用户名</th>
    	 		<th>密码</th>
    	 		<th>联系方式</th>
    	 		<th>权限</th>
    	 		<th>注册时间</th>
          <th>操作</th>
    	 	</tr>
        <?php  foreach ($ree as $key=>$value) { ?>          
    	 		<tr align='center' bgcolor="#FFFFFF" height="26" align="center" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';">
            <td width="5%"><?= $value['uid']?></td>
          <td width="10%"><?= $value['uname']?></td>
          <td width="20%"><?= $value['upassword']?></td>
           <td width="10%"><?= $value['uphone']?></td> 
           <td width="10%">
           <?php if($value['utype']==0){ ?>
           <a href="user_edit.php?uid=<?= $value['uid'] ?>&type=1"> 
              启用</a>
          <?php }elseif($value['utype']==1){ ?> 
            <a href="user_edit.php?uid=<?= $value['uid'] ?>&type=0">
              禁用</a>
           <?php } ?>  
           
            </td>           
          <td width="20%"><?= $value['time']?></td>
          <td width="10%">      
         <a href="user_edit.php?uid=<?= $value['uid'] ?>&type=3"><img src='./skin/images/frame/gtk-del.png' title="删除" alt="删除" onClick="editArc(179);" style='cursor:pointer' border='0' width='16' height='16' /></a>
          </td>
        </tr>	
      <?php  }?>
    	 	</table>

<tr align="right" bgcolor="#F9FCEF">
        <td height="36" colspan="10" align="center">
        <div class="pagelistbox" style="font-size: 18px;">
          <span>共<?php echo $totalpage;?> 1页/<?php echo $totalRows;?>条记录</span>
          <span class="indexpage">
            <a href="?page=1">首页</a>
            <a class="prevPage" href="?page=<?php echo $page-1?>">上页</a>
          </span>

            <?php for($i=1;$i<= $totalpage;$i++):?>
              <?php if($i ==$page ):?>
              <strong><?php echo $i;?></strong>

              <?php else:?>
              <a href="?page=<?php echo $i;?>"><?php echo $i;?></a>

            <?php endif;?>
            <?php endfor;?> 
              <a class="nextpage" href="?page=<?php echo $page+1;?>">下页</a>
              <a class="endpage" href="?page=<?php echo $totalPage;?>">末页</a>
        </div>
      </td>
      </tr>

		</td>
	</tr>
  </tr>
</table>
</body>
</html>
